package com.yh.javabean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Orders {
    private Integer id;
    private String orderNum;
    private Date orderTime;
    private Integer peopleCount;
    private String orderDesc;
    private Integer payType;//'支付方式（0 支付宝 1微信 2 其他',
    private Integer orderStatus;//'订单状态（0未支付1已支付）',
    private Integer productId;//'产品id外键',
    private Integer memberId;//'会员（联系人）id外键',
    private Product product;
    private Member member;
    private List<Traveller> travellers;
    private String orderTimeStr;
    private String orderStatusStr;
    private String payTypeStr;
    public String getPayTypeStr() {
        String payTypeStr="";
        if (payType == 0){
            payTypeStr = "支付宝";
        } else if(payType == 1){
            payTypeStr = "微信";
        }else if(payType == 2){
            payTypeStr = "其他";
        }
        return payTypeStr;
    }
    public String getOrderTimeStr() {
        // 对日期格式化
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        if (null != orderTime) {
            orderTimeStr=dateFormat.format(orderTime);
        }
        return orderTimeStr;
    }

    public String getOrderStatusStr() {
        if (orderStatus == null) {
            return "";
        }

        if (orderStatus == 0){
            orderStatusStr= "未支付";
        } else if(orderStatus == 1){
            orderStatusStr= "已支付";
        }else{
            return "";
        }

        return orderStatusStr;
    }
}
